import axios from 'axios'

const service = axios.create({
  baseURL: '/api',
  timeout: 5000
})

service.interceptors.request.use((config) => {
  //   const { getToken } = useToken()
  //   if (getToken()) {
  //     config.headers.Authorization = `Bearer ${getToken().token}`
  //   }
  return config
})
service.interceptors.response.use(
  (response) => {
    const { data, msg, code } = response.data
    if (code === 10000) {
      return data
    } else {
      //   Msg.error(msg)
      return Promise.reject(new Error(msg))
    }
  },
  (error) => Promise.reject(error)
)

export default service
